package com.mairuide._frame.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Description
 * @auther 刘中华
 * @create 2019-03-21 16:09
 */
public class RegUtil {
    public static List getMatcher(String regex, String source) {
        List<String> result=new ArrayList<>();
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(source);
        while (matcher.find()) {
            for (int i = 0; i < matcher.groupCount(); i++) {
                result.add(matcher.group(i+1));
            }
        }
        return result;
    }

    public static String replaceBlank(String str) {
        String dest = "";
        if (str!=null) {
            Pattern p = Pattern.compile("\t|\r|\n");
            Matcher m = p.matcher(str);
            dest = m.replaceAll("").trim();
        }
        return dest;
    }
    public static String replaceSingleQuotes(String str) {
        String dest = "";
        String regexp = "\'";
        if (StringUtils.isNotEmpty(str)) {
        	dest = str.replaceAll(regexp, "\"");
        }
        return dest;
    }
    public static void main(String[] args){
        System.out.println(replaceBlank("2016-04-01 18:05:31"));
    }
}
